package com.example.mqtt.common.enums;

/**
 * @author qwert
 * @version 1.0.0
 * @create 2025/5/4 23:55
 **/
public enum QueueStatus {
    // 状态码: 0 - 排队中
    QUEUEING(0, "排队中"),
    // 状态码: 1 - 已完成
    COMPLETED(1, "已完成"),
    // 状态码: 2 - 排队叫号超时
    TIMEOUT(2, "排队叫号超时"),
    FORCED_END(3, "排队强制结束")
    ;

    private final int code;
    private final String message;

    QueueStatus(int code, String message) {
        this.code = code;
        this.message = message;
    }

    // 根据状态码获取枚举实例
    public static QueueStatus fromCode(int code) {
        for (QueueStatus status : values()) {
            if (status.code == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("无效的状态码: " + code);
    }

    // 获取状态码
    public int getCode() {
        return code;
    }

    // 获取状态描述
    public String getMessage() {
        return message;
    }

    @Override
    public String toString() {
        return String.format("ServiceStatus{code=%d, message='%s'}", code, message);
    }
}